x86/hvm: Fix segmentation logic for system segments
authorAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 31 Mar 2017 16:03:26 +0000 (17:03 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Thu, 6 Apr 2017 17:12:59 +0000 (18:12 +0100)
commitce07f6d8cb580a9dbb744f7e92073777b79af22a
treeecfd67ddab10ac56c55113745a20ac075bcce8d4
parent7707023e50dde71d1965cca503820eb4d1479329
x86/hvm: Fix segmentation logic for system segments

c/s c785f759718 "x86/emul: Prepare to allow use of system segments for memory
references" made alterations to hvm_virtual_to_linear_addr() to allow for the
use of system segments.

However, the determination of which segmentation mode to use was based on the
current address size from emulation.

In particular, it is wrong for system segment accesses while executing in a
compatibility mode code segment.  When long mode is active, all system
segments have a 64-bit base, and this must not be truncated during the
calculation of the linear address.  (Note that the presence and limit checks
for system segments behave the same, and are already uniformly applied in both
cases.)

Replace the existing addr_size parameter with active_cs, which gets used in
combination with current to work out which segmentation logic to use.

While here, also fix the determination of segmentation to use for vm86 mode,
which is a protected mode facility but which uses real mode segmentation.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Tim Deegan <tim@xen.org>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
xen/arch/x86/hvm/emulate.c
xen/arch/x86/hvm/hvm.c
xen/arch/x86/mm/shadow/common.c
xen/include/asm-x86/hvm/hvm.h